import time
from PIL import Image
from selenium.webdriver.common.by import By
from selenium import webdriver
import dama



driver=webdriver.Edge()
driver.maximize_window()
driver.get('http://10.59.9.32/jeewms/')

user=driver.find_element(By.NAME,'userName')
user.clear()
user.send_keys('admin')

pwd=driver.find_element(By.NAME,'password')
pwd.clear()
pwd.send_keys('llg123')
# 验证码
da=driver.save_screenshot('dama.png')
yzm=driver.find_element(By.ID,'randCodeImage')
time.sleep(2)
location=yzm.location
print(location)
size=yzm.size
print(size)
#将验证码从大截图中截出来
left=location['x']
top=location['y']
right=left+size['width']
bottom=top+size['height']
Image=Image.open('dama.png')
Image1=Image.crop((left*1.5,top*1.5,right*1.5,bottom*1.5))
Image1.save('image2.png')
time.sleep(10)

driver.find_element(By.CLASS_NAME,'finish-btn').click()